/*
 * MovePattern.cpp
 *
 *  Created on: Mar 21, 2010
 *      Author: Daniel Crown
 */

#include "MovePattern.h"
#include "Logger.h"
#include <windows.h>
#include <vector>

void MovePattern::Create(vector<int> times, vector<unsigned short> bearings, vector<float> speeds, bool repeat, int timeRand, int bearingRand, int speedRand)
{
	this->repeat = repeat;
	this->timeRand = timeRand;
	this->bearingRand = bearingRand;
	this->speedRand = speedRand;
	this->times = times;
	this->bearings = bearings;
	this->speeds = speeds;
}

int MovePattern::GetChangeTime(int i)
{
	int random = 0;

	if (timeRand > 0)
	{
		random = (rand()%(timeRand*2))-timeRand;
		//Logger::getInstance().LOG(Logger::DEBUG, "timeRand: %d, %d", random, timeRand);
	}
	return times[i] + random;
}

unsigned short MovePattern::GetChangeBearing(int i)
{
	int random = 0;

	if (bearingRand > 0)
	{
		random = (rand()%(bearingRand*2))-bearingRand;
		//Logger::getInstance().LOG(Logger::DEBUG, "bearingRand: %d", random);
	}

	return bearings[i] + random;
}

float MovePattern::GetChangeSpeed(int i)
{
	int random = 0;

	if (speedRand > 0)
	{
		random = (rand()%(speedRand*2))-speedRand;
		//Logger::getInstance().LOG(Logger::DEBUG, "speedRand: %d", random);
	}

	return speeds[i] + random;
}
